gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\generalp\multi2dicho.m

    function [Idicho]=multi2dicho(Imulti,class1)
% MULTI2DICHO decomposes multi-class problem to dichotomi.
%   [Idicho]=multi2dicho(Imulti,class1)
%
% MULTI2DICHO decompose multi-class classification problem
%   into dichotomi problem - class1 against the others.
%   
% Input:
%  Imulti [1xM] class labels \in { 1,2,...K } of multi-class problem.
%  class1 [1x1] labels which will form the first class of the 
%     dichotomi problem.
%
% Output:
%  Idicho [1xM] class labels \in {1,2}.
%

% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Written Vojtech Franc (diploma thesis) 23.12.1999, 5.4.2000
% Modifications
% 10-april-2001, V. Franc, created

indexes=[];

for i = 1:length(class1),
  indexes=[indexes,find(Imulti==class1(i))]; 
end

Idicho=2*ones(1,length(Imulti));
Idicho(indexes)=1;

return;